
const { Sequelize } = require('sequelize');
const Seq = require('../../../db');
module.exports = Seq.define('User', {
    id: {
        // 每一个字段的信息
        type: Sequelize.INTEGER(10), // 整数类型
        allowNull: false, // 不允许为空
        primaryKey: true, // 设置为主键
        autoIncrement: true // 允许自增
    },
    username: {
        type: Sequelize.STRING(255),
        allowNull: false,
    },
    age: {
        type: Sequelize.TINYINT,
        allowNull: false,
        defaultValue: 0
    },
    gender: {
        type: Sequelize.ENUM(['男', '女', '默认']), // 注意枚举类型为数组
        allowNull: false,
        defaultValue: '男'
    }
}, {
    // 用来设置字段以外的其他信息
    timestamps: false,
    paranoid: false,
    freezeTableName: true,
    tableName: 'new_users',
    indexes: [{
        name: 'uname',
        fields: ['username']
    }, {
        name: 'age',
        fields: ['age']
    }]
})